﻿
namespace NetROS.Tiers.Windows.Forms
{
	/// <summary>
	/// This is the abstract edit form for the <see cref="Entities.Konto"/> entity.
	/// </summary>
	/// <remarks>This class is overwritten by .netTiers at each generation.</remarks>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class KontoEditControlBase : System.Windows.Forms.UserControl
	{
		#region Fields
		
		//private System.Windows.Forms.TableLayoutPanel uxTableLayoutPanel;
		/// <summary>
		/// The ErrorProvider for the Entity;
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxErrorProvider;
		
		/// <summary>
		/// The BindingSource for the entity.
		///</summary>
		protected System.Windows.Forms.BindingSource uxBindingSource;
						
		
		/// <summary>
		/// TextBox for the ID property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxID;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the ID property.
		/// </summary>
		protected System.Windows.Forms.Label uxIDLabel;
		
		/// <summary>
		/// TextBox for the Sifra property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxSifra;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the Sifra property.
		/// </summary>
		protected System.Windows.Forms.Label uxSifraLabel;
		
		/// <summary>
		/// TextBox for the Naziv property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxNaziv;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the Naziv property.
		/// </summary>
		protected System.Windows.Forms.Label uxNazivLabel;
		
		/// <summary>
		/// CheckBox for the Analiticki property.
		/// </summary>
		protected System.Windows.Forms.CheckBox uxAnaliticki;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the Analiticki property.
		/// </summary>
		protected System.Windows.Forms.Label uxAnalitickiLabel;
		
		/// <summary>
		/// ComboBox for the IDTip property.
		/// </summary>
		protected System.Windows.Forms.ComboBox uxIDTip;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the IDTip property.
		/// </summary>
		protected System.Windows.Forms.Label uxIDTipLabel;
		
		/// <summary>
		/// TextBox for the IDKontoPoreza property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxIDKontoPoreza;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the IDKontoPoreza property.
		/// </summary>
		protected System.Windows.Forms.Label uxIDKontoPorezaLabel;
		
		/// <summary>
		/// DataTimePicker for the DatumOd property.
		/// </summary>
		protected System.Windows.Forms.DateTimePicker uxDatumOd;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the DatumOd property.
		/// </summary>
		protected System.Windows.Forms.Label uxDatumOdLabel;
		
		/// <summary>
		/// DataTimePicker for the DatumDo property.
		/// </summary>
		protected System.Windows.Forms.DateTimePicker uxDatumDo;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the DatumDo property.
		/// </summary>
		protected System.Windows.Forms.Label uxDatumDoLabel;
		
		/// <summary>
		/// CheckBox for the PrijenosAnaliticki property.
		/// </summary>
		protected System.Windows.Forms.CheckBox uxPrijenosAnaliticki;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the PrijenosAnaliticki property.
		/// </summary>
		protected System.Windows.Forms.Label uxPrijenosAnalitickiLabel;
		#endregion
		
		#region Main entity
		private Entities.Konto _Konto;
		/// <summary>
		/// Gets or sets the <see cref="Entities.Konto"/> entity to edit with this form.
		/// </summary>
		/// <value>The <see cref="Entities.Konto"/> instance.</value>
		public Entities.Konto Konto
		{
			get {return this._Konto;}
			set
			{
				this._Konto = value;
				if (value != null) 
				{
					this.uxBindingSource.DataSource = value;
					BindControls();
				}			
				
			}
		}
		#endregion
		
		/// <summary>
		/// Binds the controls.
		/// </summary>
		private void BindControls()
		{
			this.uxID.DataBindings.Clear();
			this.uxID.DataBindings.Add("Text", this.uxBindingSource, "ID", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxSifra.DataBindings.Clear();
			this.uxSifra.DataBindings.Add("Text", this.uxBindingSource, "Sifra", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxNaziv.DataBindings.Clear();
			this.uxNaziv.DataBindings.Add("Text", this.uxBindingSource, "Naziv", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxAnaliticki.DataBindings.Clear();
			this.uxAnaliticki.DataBindings.Add("Checked", this.uxBindingSource, "Analiticki", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxIDTip.DataBindings.Clear();
			this.uxIDTip.DataBindings.Add("SelectedValue", this.uxBindingSource, "IDTip", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxIDKontoPoreza.DataBindings.Clear();
			this.uxIDKontoPoreza.DataBindings.Add("Text", this.uxBindingSource, "IDKontoPoreza", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxDatumOd.DataBindings.Clear();
			this.uxDatumOd.DataBindings.Add("Value", this.uxBindingSource, "DatumOd", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxDatumDo.DataBindings.Clear();
			this.uxDatumDo.DataBindings.Add("Value", this.uxBindingSource, "DatumDo", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxPrijenosAnaliticki.DataBindings.Clear();
			this.uxPrijenosAnaliticki.DataBindings.Add("Checked", this.uxBindingSource, "PrijenosAnaliticki", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
		}					
		
		#region Constructor
		
		/// <summary>
		/// Initializes a new instance of the <see cref="KontoEditControlBase"/> class.
		/// </summary>
		public KontoEditControlBase()
		{
			InitializeComponent();			
			
			this.uxBindingSource.CurrentItemChanged += new System.EventHandler(uxBindingSource_currentItemChanged);
		}		
		
		/// <summary>
		/// 
		/// </summary>
		private void uxBindingSource_currentItemChanged(object sender, System.EventArgs e)
		{
			if (_Konto != null) _Konto.Validate();
		}	
				
		/// <summary>
		/// Initializes the component.
		/// </summary>
		public void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.uxErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxBindingSource = new System.Windows.Forms.BindingSource(this.components);
			
			//this.uxTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
			this.uxID = new System.Windows.Forms.TextBox();
			uxIDLabel = new System.Windows.Forms.Label();
			this.uxSifra = new System.Windows.Forms.TextBox();
			uxSifraLabel = new System.Windows.Forms.Label();
			this.uxNaziv = new System.Windows.Forms.TextBox();
			uxNazivLabel = new System.Windows.Forms.Label();
			this.uxAnaliticki = new System.Windows.Forms.CheckBox();
			uxAnalitickiLabel = new System.Windows.Forms.Label();
			this.uxIDTip = new System.Windows.Forms.ComboBox();
			uxIDTipLabel = new System.Windows.Forms.Label();
			this.uxIDKontoPoreza = new System.Windows.Forms.TextBox();
			uxIDKontoPorezaLabel = new System.Windows.Forms.Label();
			this.uxDatumOd = new System.Windows.Forms.DateTimePicker();
			uxDatumOdLabel = new System.Windows.Forms.Label();
			this.uxDatumDo = new System.Windows.Forms.DateTimePicker();
			uxDatumDoLabel = new System.Windows.Forms.Label();
			this.uxPrijenosAnaliticki = new System.Windows.Forms.CheckBox();
			uxPrijenosAnalitickiLabel = new System.Windows.Forms.Label();
			
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).BeginInit();
			this.SuspendLayout();
			
			// 
			// uxTableLayoutPanel
			// 
			//this.uxTableLayoutPanel.AutoSize = true;
			//this.uxTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
			//this.uxTableLayoutPanel.ColumnCount = 2;
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F));
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 250F));
			//this.uxTableLayoutPanel.Location = new System.Drawing.System.Drawing.Point(3, 3);
			//this.uxTableLayoutPanel.Name = "uxTableLayoutPanel";
			//this.uxTableLayoutPanel.RowCount = 2;
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.Size = new System.Drawing.Size(450, 50);
			//this.uxTableLayoutPanel.TabIndex = 0;
			
			//
			// uxErrorProvider
			//
			this.uxErrorProvider.ContainerControl = this;
			this.uxErrorProvider.DataSource = this.uxBindingSource;
			
			//
			// uxIDLabel
			//
			this.uxIDLabel.Text = "ID:";
			this.uxIDLabel.Location = new System.Drawing.Point(3, 0);
			this.Controls.Add(this.uxIDLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDLabel);			
			//
			// uxID
			//
			this.uxID.ReadOnly = true;
			//this.uxTableLayoutPanel.Controls.Add(this.uxID);
			this.uxID.Location = new System.Drawing.Point(160, 0);
			this.Controls.Add(this.uxID);
			//
			// uxSifraLabel
			//
			this.uxSifraLabel.Text = "Sifra:";
			this.uxSifraLabel.Location = new System.Drawing.Point(3, 26);
			this.Controls.Add(this.uxSifraLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxSifraLabel);			
			//
			// uxSifra
			//
			this.uxSifra.Width = 250;
			this.uxSifra.MaxLength = 9;
			//this.uxTableLayoutPanel.Controls.Add(this.uxSifra);
			this.uxSifra.Location = new System.Drawing.Point(160, 26);
			this.Controls.Add(this.uxSifra);
			//
			// uxNazivLabel
			//
			this.uxNazivLabel.Text = "Naziv:";
			this.uxNazivLabel.Location = new System.Drawing.Point(3, 52);
			this.Controls.Add(this.uxNazivLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxNazivLabel);			
			//
			// uxNaziv
			//
			this.uxNaziv.Width = 250;
			this.uxNaziv.MaxLength = 250;
			//this.uxTableLayoutPanel.Controls.Add(this.uxNaziv);
			this.uxNaziv.Location = new System.Drawing.Point(160, 52);
			this.Controls.Add(this.uxNaziv);
			//
			// uxAnalitickiLabel
			//
			this.uxAnalitickiLabel.Text = "Analiticki:";
			this.uxAnalitickiLabel.Location = new System.Drawing.Point(3, 78);
			this.Controls.Add(this.uxAnalitickiLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxAnalitickiLabel);			
			//
			// uxAnaliticki
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxAnaliticki);
			this.uxAnaliticki.Location = new System.Drawing.Point(160, 78);
			this.Controls.Add(this.uxAnaliticki);
			//
			// uxIDTipLabel
			//
			this.uxIDTipLabel.Text = "IDTip:";
			this.uxIDTipLabel.Location = new System.Drawing.Point(3, 104);
			this.Controls.Add(this.uxIDTipLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDTipLabel);			
			//
			// uxIDTip
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDTip);
			this.uxIDTip.Location = new System.Drawing.Point(160, 104);
			this.Controls.Add(this.uxIDTip);
			//
			// uxIDKontoPorezaLabel
			//
			this.uxIDKontoPorezaLabel.Text = "IDKontoPoreza:";
			this.uxIDKontoPorezaLabel.Location = new System.Drawing.Point(3, 130);
			this.Controls.Add(this.uxIDKontoPorezaLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDKontoPorezaLabel);			
			//
			// uxIDKontoPoreza
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDKontoPoreza);
			this.uxIDKontoPoreza.Location = new System.Drawing.Point(160, 130);
			this.Controls.Add(this.uxIDKontoPoreza);
			//
			// uxDatumOdLabel
			//
			this.uxDatumOdLabel.Text = "DatumOd:";
			this.uxDatumOdLabel.Location = new System.Drawing.Point(3, 156);
			this.Controls.Add(this.uxDatumOdLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxDatumOdLabel);			
			//
			// uxDatumOd
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxDatumOd);
			this.uxDatumOd.Location = new System.Drawing.Point(160, 156);
			this.Controls.Add(this.uxDatumOd);
			//
			// uxDatumDoLabel
			//
			this.uxDatumDoLabel.Text = "DatumDo:";
			this.uxDatumDoLabel.Location = new System.Drawing.Point(3, 182);
			this.Controls.Add(this.uxDatumDoLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxDatumDoLabel);			
			//
			// uxDatumDo
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxDatumDo);
			this.uxDatumDo.Location = new System.Drawing.Point(160, 182);
			this.Controls.Add(this.uxDatumDo);
			//
			// uxPrijenosAnalitickiLabel
			//
			this.uxPrijenosAnalitickiLabel.Text = "PrijenosAnaliticki:";
			this.uxPrijenosAnalitickiLabel.Location = new System.Drawing.Point(3, 208);
			this.Controls.Add(this.uxPrijenosAnalitickiLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxPrijenosAnalitickiLabel);			
			//
			// uxPrijenosAnaliticki
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxPrijenosAnaliticki);
			this.uxPrijenosAnaliticki.Location = new System.Drawing.Point(160, 208);
			this.Controls.Add(this.uxPrijenosAnaliticki);
			//
			// uxIDTip
			//				
			this.uxIDTip.DisplayMember = "Naziv";	
			this.uxIDTip.ValueMember = "ID";	
			// 
			// KontoEditControlBase
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			//this.Controls.Add(this.uxTableLayoutPanel);
			this.AutoScroll = true;
			this.Name = "KontoEditControlBase";
			this.Size = new System.Drawing.Size(478, 311);
			//this.Localizable = true;
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).EndInit();			
			this.ResumeLayout(false);
			this.PerformLayout();
		}
		#endregion
				
		#region ComboBox List
		
				
		private Entities.TList<Entities.TipKonta> _IDTipList;
		
		/// <summary>
		/// The ComboBox associated with the IDTip property.
		/// </summary>
		[System.ComponentModel.Category("ComboBox BindingSources")]
		public Entities.TList<Entities.TipKonta> IDTipList
		{
			get {return _IDTipList;}
			set 
			{
				this._IDTipList = value;
				this.uxIDTip.DataSource = null;
				this.uxIDTip.DataSource = value;
			}
		}
		
		private bool _allowNewItemInIDTipList;
		
		/// <summary>
		/// Indicates if the ComboBox associated with the IDTip property allow user to add item.
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDTipList
		{
			get { return _allowNewItemInIDTipList;}
			set
			{
				this._allowNewItemInIDTipList = value;
				this.uxIDTip.DropDownStyle = value ? System.Windows.Forms.ComboBoxStyle.DropDown : System.Windows.Forms.ComboBoxStyle.DropDownList;
			}
		}
		
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	}
}
